.class Lcom/hyphenate/chat/EMPushHelper$1;
.super Ljava/lang/Thread;


# instance fields
.field final synthetic this$0:Lcom/hyphenate/chat/EMPushHelper;


# direct methods
.method constructor <init>(Lcom/hyphenate/chat/EMPushHelper;)V
    .locals 0

    iput-object p1, p0, Lcom/hyphenate/chat/EMPushHelper$1;->this$0:Lcom/hyphenate/chat/EMPushHelper;

    invoke-direct {p0}, Ljava/lang/Thread;-><init>()V

    return-void
.end method


# virtual methods
.method public run()V
    .locals 10

    const/4 v9, 0x3

    const/4 v8, 0x1

    const/4 v1, 0x0

    const/4 v0, 0x0

    move v3, v1

    :goto_0
    if-ge v3, v9, :cond_8

    :try_start_0
    iget-object v0, p0, Lcom/hyphenate/chat/EMPushHelper$1;->this$0:Lcom/hyphenate/chat/EMPushHelper;

    invoke-virtual {v0}, Lcom/hyphenate/chat/EMPushHelper;->getDeviceToken()Ljava/lang/String;

    move-result-object v2

    if-eqz v2, :cond_1

    move-object v4, v2

    :goto_1
    if-nez v4, :cond_2

    new-instance v0, Lcom/hyphenate/chat/EMPushHelper$1$1HandleSendFail;

    invoke-direct {v0, p0}, Lcom/hyphenate/chat/EMPushHelper$1$1HandleSendFail;-><init>(Lcom/hyphenate/chat/EMPushHelper$1;)V

    invoke-virtual {v0}, Lcom/hyphenate/chat/EMPushHelper$1$1HandleSendFail;->onSendFail()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1

    :cond_0
    :goto_2
    return-void

    :cond_1
    :try_start_1
    new-instance v0, Ljava/util/Random;

    invoke-direct {v0}, Ljava/util/Random;-><init>()V

    const/16 v4, 0xa

    invoke-virtual {v0, v4}, Ljava/util/Random;->nextInt(I)I

    move-result v0

    mul-int/lit16 v0, v0, 0x3e8

    int-to-long v4, v0

    invoke-static {v4, v5}, Lcom/hyphenate/chat/EMPushHelper$1;->sleep(J)V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    :goto_3
    :try_start_2
    invoke-virtual {p0}, Lcom/hyphenate/chat/EMPushHelper$1;->isInterrupted()Z

    move-result v0

    if-nez v0, :cond_0

    add-int/lit8 v0, v3, 0x1

    move v3, v0

    move-object v0, v2

    goto :goto_0

    :catch_0
    move-exception v0

    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_1

    goto :goto_3

    :catch_1
    move-exception v0

    sget-object v1, Lcom/hyphenate/chat/EMPushHelper;->TAG:Ljava/lang/String;

    invoke-virtual {v0}, Ljava/lang/Exception;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v1, v0}, Lcom/hyphenate/util/EMLog;->e(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_2

    :cond_2
    :try_start_3
    iget-object v0, p0, Lcom/hyphenate/chat/EMPushHelper$1;->this$0:Lcom/hyphenate/chat/EMPushHelper;

    invoke-virtual {v0}, Lcom/hyphenate/chat/EMPushHelper;->getPushToken()Ljava/lang/String;

    move-result-object v0

    if-nez v0, :cond_5

    move v3, v1

    move v0, v1

    :goto_4
    if-ge v3, v9, :cond_3

    iget-object v0, p0, Lcom/hyphenate/chat/EMPushHelper$1;->this$0:Lcom/hyphenate/chat/EMPushHelper;

    invoke-virtual {v0, v4}, Lcom/hyphenate/chat/EMPushHelper;->sendDeviceInfo(Ljava/lang/String;)Z

    move-result v2

    if-ne v2, v8, :cond_4

    move v0, v2

    :cond_3
    if-nez v0, :cond_5

    new-instance v0, Lcom/hyphenate/chat/EMPushHelper$1$1HandleSendFail;

    invoke-direct {v0, p0}, Lcom/hyphenate/chat/EMPushHelper$1$1HandleSendFail;-><init>(Lcom/hyphenate/chat/EMPushHelper$1;)V

    invoke-virtual {v0}, Lcom/hyphenate/chat/EMPushHelper$1$1HandleSendFail;->onSendFail()V
    :try_end_3
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_1

    goto :goto_2

    :cond_4
    :try_start_4
    new-instance v0, Ljava/util/Random;

    invoke-direct {v0}, Ljava/util/Random;-><init>()V

    const/16 v5, 0xa

    invoke-virtual {v0, v5}, Ljava/util/Random;->nextInt(I)I

    move-result v0

    add-int/lit8 v0, v0, 0x14

    mul-int/lit16 v0, v0, 0x3e8

    int-to-long v6, v0

    invoke-static {v6, v7}, Lcom/hyphenate/chat/EMPushHelper$1;->sleep(J)V
    :try_end_4
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_2

    :goto_5
    :try_start_5
    invoke-virtual {p0}, Lcom/hyphenate/chat/EMPushHelper$1;->isInterrupted()Z

    move-result v0

    if-nez v0, :cond_0

    add-int/lit8 v0, v3, 0x1

    move v3, v0

    move v0, v2

    goto :goto_4

    :catch_2
    move-exception v0

    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    goto :goto_5

    :cond_5
    new-instance v5, Lcom/hyphenate/chat/EMRandomDelay;

    invoke-direct {v5}, Lcom/hyphenate/chat/EMRandomDelay;-><init>()V

    move v2, v1

    move v0, v1

    :goto_6
    if-nez v0, :cond_6

    iget-object v0, p0, Lcom/hyphenate/chat/EMPushHelper$1;->this$0:Lcom/hyphenate/chat/EMPushHelper;

    invoke-virtual {v0, v4}, Lcom/hyphenate/chat/EMPushHelper;->sendTokenToServer(Ljava/lang/String;)Z

    move-result v1

    if-ne v1, v8, :cond_7

    move v0, v1

    :cond_6
    if-ne v0, v8, :cond_0

    invoke-static {}, Lcom/hyphenate/chat/EMClient;->getInstance()Lcom/hyphenate/chat/EMClient;

    move-result-object v0

    invoke-virtual {v0}, Lcom/hyphenate/chat/EMClient;->cancelJob()V

    invoke-static {}, Lcom/hyphenate/chat/EMClient;->getInstance()Lcom/hyphenate/chat/EMClient;

    move-result-object v0

    invoke-virtual {v0}, Lcom/hyphenate/chat/EMClient;->doStopService()V
    :try_end_5
    .catch Ljava/lang/Exception; {:try_start_5 .. :try_end_5} :catch_1

    goto/16 :goto_2

    :cond_7
    add-int/lit8 v3, v2, 0x1

    :try_start_6
    invoke-virtual {v5, v2}, Lcom/hyphenate/chat/EMRandomDelay;->timeDelay(I)I

    move-result v0

    mul-int/lit16 v0, v0, 0x3e8

    int-to-long v6, v0

    invoke-static {v6, v7}, Lcom/hyphenate/chat/EMPushHelper$1;->sleep(J)V
    :try_end_6
    .catch Ljava/lang/Exception; {:try_start_6 .. :try_end_6} :catch_3

    :goto_7
    :try_start_7
    invoke-virtual {p0}, Lcom/hyphenate/chat/EMPushHelper$1;->isInterrupted()Z

    move-result v0

    if-nez v0, :cond_0

    move v2, v3

    move v0, v1

    goto :goto_6

    :catch_3
    move-exception v0

    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V
    :try_end_7
    .catch Ljava/lang/Exception; {:try_start_7 .. :try_end_7} :catch_1

    goto :goto_7

    :cond_8
    move-object v4, v0

    goto/16 :goto_1
.end method
